package action;

import dao.BookDao;
import po.Book;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet(urlPatterns = "/user/action/someBookServlet")
public class someBookServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取title
        String title = req.getParameter("title");
        BookDao bookDao = new BookDao();
        ArrayList<Book> books = bookDao.findByTitle(title);
        //绑定数据
        req.setAttribute("books",books);
        //跳转到主页 转发
        req.getRequestDispatcher("../page/index.jsp").forward(req,resp);
    }
}
